package cn.ywsj.ywsjmidtier.controller;

import cn.ywsj.ywsjmidtier.entity.VO.*;
import cn.ywsj.ywsjmidtier.service.WechatCPCNFeign;
import cn.ywsj.ywsjmidtier.utils.JsonObjectUtil;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.bind.BindResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@Api(tags = "个人资产")
@RestController
@RequestMapping("/wechat/cpcnmgr")
public class WechatCPCNController {
    @Autowired
    private WechatCPCNFeign wechatCPCNFeign;

    /**
     * 我的钱包
     * @return
     */
    @ApiOperation("我的钱包")
    @GetMapping("/querytx4691companyaccount")
    public String queryTx4691CompanyAccount(){
        return wechatCPCNFeign.queryTx4691CompanyAccount();
    }

    /**
     * 开户账号信息
     * @param userType
     * @return
     */
    @ApiOperation("开户账号信息")
    @GetMapping("/getopenaccount")
    public String toOpenAccount(Integer userType){
      return wechatCPCNFeign.getopenaccount(userType);
    }

    /**
     * 保存开户账号
     * @param openAccountVo
     * @param result
     * @return
     */
    @ApiOperation("保存开户账号")
    @PostMapping("/saveindividualopenaccount")
    public String saveindividualopenaccount(OpenAccountVo openAccountVo, BindResult result){
        /*MultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
        map.add("phoneNumber",openAccountVo.getPhoneNumber());
        map.add("userName",openAccountVo.getUserName());
        map.add("credentialNumber",openAccountVo.getCredentialNumber());
        map.add("indAddress",openAccountVo.getIndAddress());
        map.add("indEmail",openAccountVo.getIndEmail());*/
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(openAccountVo);
        return wechatCPCNFeign.saveindividualopenaccount(jsonObject,result);
    }

    /**
     * 用户绑定银行卡列表
     * @param bindingCardVo
     * @param start
     * @param pageSize
     * @return
     */
    @ApiOperation("用户绑定银行卡列表")
    @GetMapping("/tountiebindingcard")
    public String tountiebindingcard(BindingCardVo bindingCardVo,Integer start, Integer pageSize){
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(bindingCardVo);
        return wechatCPCNFeign.tountiebindingcard(jsonObject,start,pageSize);
    }

    /**
     * 绑定银行卡列表
     * @param start
     * @param pageSize
     * @return
     */
    @ApiOperation("绑定银行卡列表")
    @GetMapping("/querybindingcardlist")
    public String querybindingcardlist(Integer start,Integer pageSize){
      return wechatCPCNFeign.querybindingcardlist(start,pageSize);
    }

    /**
     * 绑卡详情
     * @param bindingCardId
     * @return
     */
    @ApiOperation("绑卡详情")
    @GetMapping("/toseebindingcard")
    public String toseebindingcard(Integer bindingCardId){
      return wechatCPCNFeign.toseebindingcard(bindingCardId);
    }

    /**
     * 银行列表
     * @param type
     * @return
     */
    @ApiOperation("银行列表")
    @GetMapping("/querypageselectvalue")
    public String querypageselectvalue(String type){
      return wechatCPCNFeign.querypageselectvalue(type);
    }

    /**
     * 解绑银行卡
     * @param bindingCardVo
     * @return
     */
    @ApiOperation("解绑银行卡")
    @PostMapping("/savebindingcard")
    public String savebindingcard(BindingCardVo bindingCardVo){
        /*MultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
        map.add("bankAccountNumber",bindingCardVo.getBankAccountNumber());
        map.add("operationFlag",bindingCardVo.getOperationFlag());
        map.add("bindingCardName",bindingCardVo.getBindingCardName());
        map.add("bindingCardId",bindingCardVo.getBindingCardId());
        map.add("bindingWay",bindingCardVo.getBindingWay());
        map.add("bankCardType",bindingCardVo.getBankCardType());
        map.add("bindingBank",bindingCardVo.getBankId());
        map.add("branchName",bindingCardVo.getBranchName());
        map.add("bankAccountType",bindingCardVo.getBankAccountType());
        map.add("credentialType",bindingCardVo.getCredentialType());
        map.add("acceptanceConfirmType",bindingCardVo.getAcceptanceConfirmType());*/
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(bindingCardVo);
        return wechatCPCNFeign.savebindingcard(jsonObject);
    }

    /**
     * 提现用户列表
     * @return
     */
    @ApiOperation("提现用户列表")
    @GetMapping("/gettx4641recharge")
    public String gettx4641recharge(){
     return wechatCPCNFeign.gettx4641recharge();
    }

    /**
     * 充值列表
     * @param start
     * @param pageSize
     * @return
     */
    @ApiOperation("充值列表")
    @GetMapping("/queryrechargerecord")
    public String queryrechargerecord(Integer start,Integer pageSize){
        return wechatCPCNFeign.queryrechargerecord(start,pageSize);
    }

    /**
     * 购物车_在线支付Strin
     * @param mainOrderId
     * @param payType
     * @param paymentWay
     * @param request
     * @return
     */
    @ApiOperation("购物车_在线支付Strin")
    @PostMapping({"/onlinepayment"})
    public String creatOnlinePayment(String mainOrderId, Integer payType, Integer paymentWay, HttpServletRequest request){
        return wechatCPCNFeign.creatOnlinePayment(mainOrderId,payType,paymentWay,request);
    }

    @GetMapping("/toaddphotocopies")
    public String toAddPhotocopies(){
        return wechatCPCNFeign.toAddPhotocopies();
    }

    @PostMapping("/ajaxaddphotocopies")
    public String addPhotocopies(PhotocopiesVo photocopiesVo,BindResult result){
      return wechatCPCNFeign.addPhotocopies(photocopiesVo,result);
    }

    @GetMapping("/getphotocopiesinfo")
    public String toUpdatePhotocopies(PhotocopiesQueryVo photocopiesQueryVo){
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(photocopiesQueryVo);
        return wechatCPCNFeign.toUpdatePhotocopies(jsonObject);
    }

    @PostMapping("/ajaxupdatephotocopies")
    public String updatePhotocopies(PhotocopiesVo photocopiesVo,BindResult result){
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(photocopiesVo);
        return wechatCPCNFeign.updatePhotocopies(jsonObject,result);
    }

    @PostMapping("/syncphotocopies")
    public String syncPhotocopies(PhotocopiesVo photocopiesVo){
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(photocopiesVo);
        return wechatCPCNFeign.syncPhotocopies(jsonObject);
    }


    @PostMapping("/savecorporationopenaccount")
    public String saveCorporationOpenAccount(OpenAccountVo openAccountVo,BindResult result){
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(openAccountVo);
        return wechatCPCNFeign.saveCorporationOpenAccount(jsonObject,result);
    }

    @PostMapping("/saveretaileropenaccount")
    public String saveRetailerOpenAccount(OpenAccountVo openAccountVo,BindResult result){
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(openAccountVo);
        return wechatCPCNFeign.saveRetailerOpenAccount(jsonObject,result);
    }

    @GetMapping("/queryAreadInfoByPidAndLevel")
    public String queryAreadInfoByPidAndLevel(OpenAccountVo openAccountVo){
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(openAccountVo);
        return wechatCPCNFeign.queryAreadInfoByPidAndLevel(jsonObject);
    }

    @GetMapping("/querypreareainfobyid")
    public String queryPreAreaInfoById(CpcnAreaInfoVo cpcnAreaInfoVo){
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(cpcnAreaInfoVo);
        return wechatCPCNFeign.queryPreAreaInfoById(jsonObject);
    }

    @GetMapping("/tobindingcard")
    public String toBindingCard(){
        return wechatCPCNFeign.toBindingCard();
    }

    @GetMapping("/getmodifybindingcard")
    public String toModifyBindingCard(BindingCardVo bindingCardVo){
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(bindingCardVo);
        return wechatCPCNFeign.toModifyBindingCard(jsonObject);
    }

    @PostMapping("/modifybindingcard")
    public String ModifyBindingCard(BindingCardVo bindingCardVo){
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(bindingCardVo);
        return wechatCPCNFeign.ModifyBindingCard(jsonObject);
    }

    @GetMapping("/querycardbininfo")
    public String queryCardBinInfo(BindingCardVo bindingCardVo){
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(bindingCardVo);
        return wechatCPCNFeign.queryCardBinInfo(jsonObject);
    }

    @GetMapping("/getverifybindingcard")
    public String toVerifyBindingCard(BindingCardVo bindingCardVo){
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(bindingCardVo);
        return wechatCPCNFeign.toVerifyBindingCard(jsonObject);
    }


    @PostMapping("/checkpaypassword")
    public String checkPayPassword(String payPassword){
        return wechatCPCNFeign.checkPayPassword(payPassword);
    }

    @PostMapping("/verifybindingcard")
    public String verifyBindingCard(BindingCardVeriVo bindingCardVeriVo){
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(bindingCardVeriVo);
        return wechatCPCNFeign.verifyBindingCard(jsonObject);
    }
    @GetMapping("/torechargedetail")
    public String toRechargeDetail(RechargeVo rechargeVo){
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(rechargeVo);
        return wechatCPCNFeign.toRechargeDetail(jsonObject);
    }
    @PostMapping("/savetx4643withdrawal")
    public String saveTx4643Withdrawal(WithdrawalVo withdrawalVo){
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(withdrawalVo);
        return wechatCPCNFeign.saveTx4643Withdrawal(jsonObject);
    }
    @GetMapping("/withdrawalrecordlist")
    public String withdrawalRecordList(WithdrawalVo withdrawalVo){
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(withdrawalVo);
        return wechatCPCNFeign.withdrawalRecordList(jsonObject);
    }
    @GetMapping("/towithdrawaldetail")
    public String toWithdrawalDetail(WithdrawalVo withdrawalVo){
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(withdrawalVo);
        return wechatCPCNFeign.toWithdrawalDetail(jsonObject);
    }
    @GetMapping("/transferaccountrecordlist")
    public String transferAccountRecordList(CpcnTransferAccountVo cpcnTransferAccountVo){
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(cpcnTransferAccountVo);
        return wechatCPCNFeign.transferAccountRecordList(jsonObject);
    }
    @GetMapping("/totransaccdetail")
    public String totransaccdetail(CpcnTransferAccountVo cpcnTransferAccountVo){
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(cpcnTransferAccountVo);
        return wechatCPCNFeign.totransaccdetail(jsonObject);
    }
    @PostMapping("/tx4671membertransfer")
    public String tx4671MemberTransfer(CpcnTransferAccountVo cpcnTransferAccountVo){
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(cpcnTransferAccountVo);
        return wechatCPCNFeign.tx4671MemberTransfer(jsonObject);
    }
    @GetMapping("/querytransferable")
    public String queryTransferable(CompanyQueryVo companyQueryVo){
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(companyQueryVo);
        return wechatCPCNFeign.queryTransferable(jsonObject);
    }

}
